home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Borland
/
Borland C++ V5.02
/
APPEXPRT.PAK
/
TDIALOG.OWL
< prev
next >
Wrap
Text File
|
1997-05-06
|
7KB
|
254 lines
'------------------------------------------------------------------------------
' Expert - (C) Copyright 1993, 1995 by Borland International, Inc.
' All Rights Reserved.
'
' SUBSYSTEM: OWL code template
' FILE: TDialog.OWL
'
'
' OVERVIEW
' ~~~~~~~~
' Definition of all OWL classes when can be generated by the CODEGEN phase of
' AppGen and ClassExpert. AppGen generates when all options have been selected
' and multiple classes are generated. ClassExpert uses the CODEGEN phase when
' a new class is generated.
'------------------------------------------------------------------------------
<<[H]TDialog [[TDialog]]
##{hheader.snp}
#include <owl/static.h>
##<<TApplication QUERY_FILENAME_CPP [[Filename]]
#include "[[Filename]].rh" // Definition of all resources.
//{{TDialog = [[TDialog]]}}
class [[TDialog]] : public TDialog {
public:
##QUERY_DLOG [[DLogRsrc]]
[[TDialog]](TWindow* parent, TResId resId = [[DLogRsrc]], TModule* module = 0);
virtual ~[[TDialog]]();
//{{[[TDialog]]VIRTUAL_BEGIN}}
public:
void SetupWindow();
##:DBVirtual(\\"[[TDialog]]", "SetupWindow")
//{{[[TDialog]]VIRTUAL_END}}
}; //{{[[TDialog]]}}
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Reading the VERSIONINFO resource.
//
class TProjectRCVersion {
public:
TProjectRCVersion(TModule* module);
virtual ~TProjectRCVersion();
bool GetProductName(LPSTR& prodName);
bool GetProductVersion(LPSTR& prodVersion);
bool GetCopyright(LPSTR& copyright);
bool GetDebug(LPSTR& debug);
protected:
uint8 far* TransBlock;
void far* FVData;
private:
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Don't allow this object to be copied.
//
TProjectRCVersion(const TProjectRCVersion&);
TProjectRCVersion& operator = (const TProjectRCVersion&);
};
##{hfooter.snp}
>>[H]TDialog [[TDialog]]
'
' TDialog CPP file.
'
<<[CPP]TDialog [[TDialog]]
##{cheader.snp}
#include <owl/pch.h>
#include <stdio.h>
#if defined(BI_PLAT_WIN16)
# include <ver.h>
#endif
##<<TApplication QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
##QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
TProjectRCVersion::TProjectRCVersion(TModule* module)
{
uint32 fvHandle;
uint vSize;
char appFName[255];
TAPointer<char> subBlockName = new char[255];
FVData = 0;
module->GetModuleFileName(appFName, sizeof appFName);
OemToAnsi(appFName, appFName);
uint32 dwSize = ::GetFileVersionInfoSize(appFName, &fvHandle);
if (dwSize) {
FVData = (void far *)new char[(uint)dwSize];
if (::GetFileVersionInfo(appFName, fvHandle, dwSize, FVData)) {
// Copy string to buffer so if the -dc compiler switch(Put constant strings in code segments)
// is on VerQueryValue will work under Win16. This works around a problem in Microsoft's ver.dll
// which writes to the string pointed to by subBlockName.
//
strcpy(subBlockName, "\\VarFileInfo\\Translation");
if (!::VerQueryValue(FVData, subBlockName,(void far* far*)&TransBlock, &vSize)) {
delete[] FVData;
FVData = 0;
}
else
// Swap the words so sprintf will print the lang-charset in the correct format.
//
*(uint32 *)TransBlock = MAKELONG(HIWORD(*(uint32 *)TransBlock), LOWORD(*(uint32 *)TransBlock));
}
}
}
TProjectRCVersion::~TProjectRCVersion()
{
if (FVData)
delete[] FVData;
}
bool TProjectRCVersion::GetProductName(LPSTR& prodName)
{
uint vSize;
TAPointer<char> subBlockName = new char[255];
if (FVData) {
sprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(uint32 *)TransBlock,(LPSTR)"ProductName");
return FVData ? ::VerQueryValue(FVData, subBlockName,(void far* far*)&prodName, &vSize) : false;
} else
return false;
}
bool TProjectRCVersion::GetProductVersion(LPSTR& prodVersion)
{
uint vSize;
TAPointer<char> subBlockName = new char[255];
if (FVData) {
sprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(uint32 *)TransBlock,(LPSTR)"ProductVersion");
return FVData ? ::VerQueryValue(FVData, subBlockName,(void far* far*)&prodVersion, &vSize) : false;
} else
return false;
}
bool TProjectRCVersion::GetCopyright(LPSTR& copyright)
{
uint vSize;
TAPointer<char> subBlockName = new char[255];
if (FVData) {
sprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(uint32 *)TransBlock,(LPSTR)"LegalCopyright");
return FVData ? ::VerQueryValue(FVData, subBlockName,(void far* far*)©right, &vSize) : false;
} else
return false;
}
bool TProjectRCVersion::GetDebug(LPSTR& debug)
{
uint vSize;
TAPointer<char> subBlockName = new char[255];
if (FVData) {
sprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(uint32 *)TransBlock,(LPSTR)"SpecialBuild");
return FVData ? ::VerQueryValue(FVData, subBlockName,(void far* far*)&debug, &vSize) : false;
} else
return false;
}
//{{[[TDialog]] Implementation}}
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//--------------------------------------------------------
// [[TDialog]]
// ~~~~~~~~~~
// Construction/Destruction handling.
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
[[TDialog]]::[[TDialog]](TWindow* parent, TResId resId, TModule* module)
:
TDialog(parent, resId, module)
{
// INSERT>> Your constructor code here.
}
[[TDialog]]::~[[TDialog]]()
{
Destroy();
// INSERT>> Your destructor code here.
}
void [[TDialog]]::SetupWindow()
{
LPSTR prodName = 0, prodVersion = 0, copyright = 0, debug = 0;
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Get the static text for the value based on VERSIONINFO.
//
TStatic* versionCtrl = new TStatic(this, IDC_VERSION, 255);
TStatic* copyrightCtrl = new TStatic(this, IDC_COPYRIGHT, 255);
TStatic* debugCtrl = new TStatic(this, IDC_DEBUG, 255);
TDialog::SetupWindow();
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Process the VERSIONINFO.
//
TProjectRCVersion applVersion(GetModule());
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Get the product name and product version strings.
//
if (applVersion.GetProductName(prodName) && applVersion.GetProductVersion(prodVersion)) {
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// IDC_VERSION is the product name and version number, the initial value of IDC_VERSION is
// the word Version(in whatever language) product name VERSION product version.
//
char buffer[255];
char versionName[128];
buffer[0] = '\0';
versionName[0] = '\0';
versionCtrl->GetText(versionName, sizeof versionName);
sprintf(buffer, "%s %s %s", prodName, versionName, prodVersion);
versionCtrl->SetText(buffer);
}
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Get the legal copyright string.
//
if (applVersion.GetCopyright(copyright))
copyrightCtrl->SetText(copyright);
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Only get the SpecialBuild text if the VERSIONINFO resource is there.
//
if (applVersion.GetDebug(debug))
debugCtrl->SetText(debug);
}
>>[CPP]TDialog [[TDialog]]